//
//  NewsContentModel.m
//  WanCaiC8
//
//  Created by tangang on 2018/4/22.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "NewsContentModel.h"

@implementation NewsContentModel

-(void)setContent:(NSString *)Content{
    NSString *strContent=[Content stringByReplacingOccurrencesOfString:@"<p><br></p>" withString:@""];
    strContent=[NSString stringWithFormat:@"%@",strContent];
    strContent = [strContent stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
    
    //MARK:
    if ([strContent containsString:@".jpg"]) {
        strContent=[strContent stringByReplacingOccurrencesOfString:@".jpg\"" withString:[NSString stringWithFormat:@".jpg\" width=\"%.0f\"",SCREEN_WIDTH-20]];
    }
    if ([strContent containsString:@".png"]) {
        strContent=[strContent stringByReplacingOccurrencesOfString:@".png\"" withString:[NSString stringWithFormat:@".png\" width=\"%.0f\"",SCREEN_WIDTH-20]];
    }
    
    
//    strContent=[NSString stringWithFormat:@"<font size=\"5\">%@</font>",strContent];
//    strContent =[strContent stringByReplacingOccurrencesOfString:@"<p>" withString:@"<p style='line-height:30px;'>"];
    _Content=strContent;
}

- (void)setAdModel:(AdvertisingModel *)adModel{
    if (adModel.Title.length<1) {
        return;
    }
    _adModel=adModel;
    NSMutableArray *arr=[[self.Content componentsSeparatedByString:@"</p>"] mutableCopy];
    if (arr.count>1) {
        self.row=(NSInteger)arr.count/1.42;
        [arr insertObject:[NSString stringWithFormat:@"<p>%@",adModel.Title] atIndex:self.row];
        self.Content=[arr componentsJoinedByString:@"</p>"];
    }else{
        NSMutableArray *arr=[[self.Content componentsSeparatedByString:@"</br>"] mutableCopy];
        self.row=(NSInteger)arr.count/1.42;
        [arr insertObject:[NSString stringWithFormat:@"%@</br>",adModel.Title] atIndex:self.row];
        self.Content=[arr componentsJoinedByString:@"</br>"];
    }
}

@end


@implementation OtherNewsModel
@end

@implementation ShareModel
@end
